package datastructure.ch05_queues.ch06_circle_queue;

import datastructure.ch05_queues.ch02_interface_abstarct.Deque;

/**
 * 
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
@SuppressWarnings("unchecked")
public class DoubleCircleQueue<E> implements Deque<E> {
    public static void main(String[] args) {
        DoubleCircleQueue<Integer> data = new DoubleCircleQueue<>();
    }

    E[] elementData;
    int size;
    int front;

    public DoubleCircleQueue() {
        elementData = (E[]) new Object[10];
    }

    @Override
    public int size() {
        return size;
    }

    @Override
    public boolean isEmpty() {
        return size == 0;
    }

    @Override
    public void clear() {
        for (int i = 0; i < size; i++) {
            elementData[i] = null;
        }
        front = 0;
        size = 0;
    }

    @Override
    public void enqueueFront(E e) {

    }

    @Override
    public void enqueueTail(E e) {

    }

    @Override
    public E dequeueFront() {
        return null;
    }

    @Override
    public E dequeueTail() {
        return null;
    }

    @Override
    public E getFront() {
        return elementData[front];
    }

    @Override
    public E getTail() {
        return elementData[(front + size - 1) % elementData.length];
    }

    private int index(int index) {
        index += size;
        if (index < 0) {
            return index + elementData.length;
        }
        return index % elementData.length;
    }
}
